package nancal.mp.db.mongo.table

import java.io.*
import nbcp.base.db.*
import nbcp.base.comm.*
import nbcp.base.extend.*
import nbcp.base.enums.*
import nbcp.base.utils.*
import nbcp.myoql.db.*
import nbcp.myoql.db.comm.*
import nbcp.myoql.db.enums.*
import nbcp.myoql.db.mongo.*
import nbcp.myoql.db.mongo.base.*
import nbcp.myoql.db.mongo.component.*
import org.slf4j.LoggerFactory
import org.springframework.stereotype.*


@Component("mongo.cms")
@MetaDataGroup(DatabaseEnum.Mongo, "cms")
class CmsGroup : IDataGroup {
    override fun getEntities(): Set<BaseMetaData<out Any>> = setOf(article, articleFavorite, articleGroup)



    val article get() = ArticleEntity();




    val articleFavorite get() = ArticleFavoriteEntity();




    val articleGroup get() = ArticleGroupEntity();



    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """cms""")
    class ArticleEntity(collectionName: String = "article") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.Article>(nancal.mp.db.mongo.entity.Article::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val name = MongoColumnName("name")

        val code = MongoColumnName("code")

        val groups = IdNameMeta("groups")

        val author = MongoColumnName("author")

        val logo = IdUrlMeta("logo")

        val tags = SetMeta("tags")

        val body = MongoColumnName("body")

        val corp = IdNameMeta("corp")

        val order = MongoColumnName("order")

        val link = MongoColumnName("link")

        val linkArticles = IdNameMeta("linkArticles")

        val linkProducts = IdNameUrlMeta("linkProducts")

        val discussions = DiscussItemMeta("discussions")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """cms""")
    class ArticleFavoriteEntity(collectionName: String = "articleFavorite") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.ArticleFavorite>(nancal.mp.db.mongo.entity.ArticleFavorite::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val article = IdNameMeta("article")

        val user = IdNameMeta("user")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """cms""")
    class ArticleGroupEntity(collectionName: String = "articleGroup") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.ArticleGroup>(nancal.mp.db.mongo.entity.ArticleGroup::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val name = MongoColumnName("name")

        val code = MongoColumnName("code")

        val pwbs = MongoColumnName("pwbs")

        val order = MongoColumnName("order")

        val corp = IdNameMeta("corp")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }

}

